//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.util;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.Iterator;
import java.util.Set;

public class JsonUtils {
    public JsonUtils() {
    }

    public static Object findValueByKey(JSONObject json, String key) {
        Set<String> keySet = json.keySet();
        Iterator var3 = keySet.iterator();

        while(true) {
            while(var3.hasNext()) {
                String k = (String)var3.next();
                Object v = json.get(k);
                if (k.equals(key)) {
                    return v;
                }

                if (v instanceof JSONArray) {
                    int size = ((JSONArray)v).size();

                    for(int i = 0; i <= size - 1; ++i) {
                        Object result = findValueByKey((JSONObject)((JSONArray)v).get(i), key);
                        if (result != null) {
                            return result;
                        }
                    }
                } else if (v instanceof JSONObject) {
                    Object result = findValueByKey((JSONObject)v, key);
                    if (result != null) {
                        return result;
                    }
                }
            }

            return null;
        }
    }
}
